/*
 * @Author: zhangweixin 
 * @Date: 2019-03-30 22:21:18 
 * @Last Modified by: zhangweixin
 * @Last Modified time: 2019-03-30 22:32:44
 */
// options === app.config.robot
module.exports = (options, app) => {
    return async function robotMiddleware(ctx, next) {
      const source = ctx.get('user-agent') || '';
      console.log(source)
      console.log(options)
      const match = options.ua.some(ua => ua.test(source));
      if (match) {
        ctx.status = 403;
        ctx.message = 'Go away, robot.';
      } else {
          console.log(2)
        await next();
      }
    }
  };
  